﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Wicresoft.Shell.Package.AppExp
{
    public partial class NewProfForm : Form
    {

        public string Key = string.Empty;
        public string Value = string.Empty;
        public string TypeName = string.Empty;

        public NewProfForm()
        {
            InitializeComponent();
            PrivateInitial();
        }

        private void PrivateInitial()
        {
            lsvType.Items.Add(new ListViewItem("Velocity Template", 1));
            lsvType.Items.Add(new ListViewItem("XSL Template", 0));
            lsvType.Items.Add(new ListViewItem("Txt Template", 2));
            lsvType.Items.Add(new ListViewItem("Html Template", 3));
            lsvType.Items[0].Selected = true;
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (lsvType.SelectedItems.Count == 0)
            {
                MessageBox.Show("You must select a template type!");
            }
            else if (txtKey.Text == string.Empty)
            {
                MessageBox.Show("The Key mustn't empty!");
            }
            else
            {
                switch (lsvType.SelectedItems[0].Text)
                {
                    case "Velocity Template":
                        TypeName = "vm";
                        break;
                    case "XSL Template":
                        TypeName = "xsl";
                        break;
                    case "Txt Template":
                        TypeName = "txt";
                        break;
                    case "Html Template":
                        TypeName = "html";
                        break;
                    default: break;
                }
                Key = txtKey.Text;
                Value = txtValue.Text;
                this.DialogResult = DialogResult.OK;
                this.Close();
            }

        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }
}
